package top.yueyazhui.rate_limiter.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.yueyazhui.rate_limiter.annotation.RateLimiter;
import top.yueyazhui.rate_limiter.enums.LimitType;

@RestController
@RequestMapping("/hello")
public class HelloController {

    /**
     * 限流：每 30 秒，只能请求 3 次，限流类型 IP
     */
    @RateLimiter(time = 30, count = 3, limitType = LimitType.IP)
    @GetMapping("/")
    public String hello() {
        return "hello";
    }
}
